#pragma once
#include "base.h"
#include "IScreenManager.h"
#include "IGameScreen.h"
#include "IGame.h"
#include "TypeDefs.h"
#include <list>
using namespace std;

class ScreenManager : public IScreenManager
{
public:
	ScreenManager(void);
	~ScreenManager(void);

public:
	//Dump open screens to console
	void DumpScreensToSTD();
	//Initializes the screenmanager
	bool Init(IGame *pGame);
	//Adds a screen after the base screen if pScreenBase is NULL the screen is added as the topmost screen
	bool AddScreenAfter(GameScreenPtr spScreen, IGameScreen *pScreenBase = NULL);
	//Adds a screen before the base screen if pScreenBase is NULL the screen is added as the bottom screen
	bool AddScreenBefore(GameScreenPtr spScreen, IGameScreen *pScreenBase = NULL);
	//Request a screen to be removed
	void RequestScreenRemoval(IGameScreen *pScreen);
	//Instantly remove a screen
	void RemoveScreen(IGameScreen *pScreen);
	//Returns the number of screens
	uint GetScreenCount();
	//Gets the screen at a position
	GameScreenPtr GetScreenAt(int index);
	//Gets the topmost screen
	GameScreenPtr GetTopScreen();
	//Gets the bottom screen
	GameScreenPtr GetBaseScreen();
	//Screen manager cleanup
	void Cleanup();
	//Input Handlers
	void OnKeyPress(uint key);
	void OnKeyRelease(uint key);
	uint GetKeyMod();

	//Updates all the screens
	void Update();
	//Renders all the screens
	void Render();

protected:
	//Initializes a screen to be used
	bool InitializeScreen(GameScreenPtr spScreen);

protected:
	IGame *m_pGame;
	list<GameScreenPtr> m_screens;
};

